package com.hvgroup.modules.sanic.service.factory;

import com.hvgroup.modules.sanic.domain.enums.ChartTypeEnum;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class ChartHandlerFactory {

    private final Map<ChartTypeEnum, ChartHandler> handlerMap;

    public ChartHandlerFactory(List<ChartHandler> handlers) {
        this.handlerMap = new HashMap<>();
        for (ChartHandler handler : handlers) {
            handlerMap.put(handler.getChartType(), handler);
        }
    }

    public ChartHandler getHandler(ChartTypeEnum chartType) {
        return handlerMap.get(chartType);
    }
}